#include <iostream>
#include <fstream>
#include <cstdlib>
#include <vector>
#include <ctime>
#include <iomanip>

using namespace std;

struct move
{
    public:
        short _from;
        short _to;
        move(){}
        move(short  f, short  t): _from(f), _to(t){}
};

class GameTreeNode
{

    public:
    /* Data Member */
        int     _round;
        int     _score;
        int     _pieceScore[32];
        bool    _stop;
        short   _depth;
        short   _board[32];
        short   _piece[32];
        GameTreeNode* _route;
        
        move _path;
        vector<GameTreeNode*> _child;
    
    /* Member Function */
        GameTreeNode(move);
        GameTreeNode(short, move, short*, short*, bool);  // Constructor
        
        int utility();
        int CapMove();
        int ProbeHash(int, int);
        void RecordHash(int, int);
        void evaluation();
        void stop_check();
        void GenerateLegalMoves(short);
        bool Win();
};



class GameTree
{
    public:
        /* Data Member */
        short _height;
        GameTreeNode* _root;
        vector<GameTreeNode*> _route;
    
        /* Member Function */
        GameTree(){                            // Consturctor
            _root = NULL;
        }
        GameTree(short*, short*, short, bool); // Consturctor
        ~GameTree();
        void destroyTree(GameTreeNode* node);
        void destroySubtree(GameTreeNode*);
        GameTreeNode* cutChild(int);
        void printTree();
        void printTreeJS();
        void printTreeRe(GameTreeNode*, ofstream&, int);
        int printTreeReJS(GameTreeNode*, ofstream&);
        void printMove(GameTreeNode*);
        int AlphaBeta(GameTreeNode* ,short ,int ,int ,GameTreeNode* & );
        void GameTree::traceRoute();
        int IDS(short , GameTreeNode* & );
        void delall(GameTreeNode*);

        //void createTree();
        //void growTree(GameTreeNode*, int);
};
